this.BX=this.BX||{};this.BX.UI=this.BX.UI||{};(function(e,t,r){"use strict";var n=function(e){babelHelpers.inherits(t,e);function t(e){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,{data:e}))}return t}(r.Event.BaseEvent);var i=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){babelHelpers.defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var s=function(e){babelHelpers.inherits(t,e);function t(){var e;var n=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};babelHelpers.classCallCheck(this,t);e=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(e),"originalDragStartEvent",null);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(e),"dragStartEvent",null);e.setEventNamespace("BX.UI.DragAndDrop.Draggable.Sensor");var a=i.dropzone;e.containers=r.Type.isArray(n)?babelHelpers.toConsumableArray(n):[n];e.dropzones=r.Type.isArrayLike(a)?babelHelpers.toConsumableArray(a):[a];e.options=o({delay:0},i);return e}babelHelpers.createClass(t,[{key:"getDocument",value:function e(){return this.options.context.document}},{key:"addContainer",value:function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++){r[n]=arguments[n]}this.containers=[].concat(babelHelpers.toConsumableArray(this.containers),r)}},{key:"removeContainer",value:function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++){r[n]=arguments[n]}this.containers=this.containers.filter((function(e){return!r.includes(e)}))}},{key:"getContainerByChild",value:function e(t){return this.containers.find((function(e){return e.contains(t)}))}},{key:"addDropzone",value:function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++){r[n]=arguments[n]}this.dropzones=[].concat(babelHelpers.toConsumableArray(this.dropzones),r)}},{key:"removeDropzone",value:function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++){r[n]=arguments[n]}this.dropzones=this.dropzones.filter((function(e){return!r.includes(e)}))}},{key:"getDropzoneByChild",value:function e(t){return this.dropzones.find((function(e){return e.contains(t)}))}},{key:"getElementFromPoint",value:function e(t,r){return this.getDocument().elementFromPoint(t,r)}},{key:"preventDefaultEventAction",value:function e(t){if(t.cancelable){t.preventDefault()}}},{key:"isDragging",value:function e(){return this.dragStartEvent&&!this.dragStartEvent.isDefaultPrevented()}},{key:"enable",value:function e(){return this}},{key:"disable",value:function e(){return this}},{key:"getDragElementByChild",value:function e(t){if(t){var r=this.options.dragElement;return t.closest(r)||null}return null}}]);return t}(t.EventEmitter);var l=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var u=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var c=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var h=function(e){babelHelpers.inherits(t,e);function t(){var e;var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};babelHelpers.classCallCheck(this,t);e=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,r,n));e.mousedownTimeoutId=null;e.onMouseDown=e.onMouseDown.bind(babelHelpers.assertThisInitialized(e));e.onMouseMove=e.onMouseMove.bind(babelHelpers.assertThisInitialized(e));e.onMouseUp=e.onMouseUp.bind(babelHelpers.assertThisInitialized(e));e.onDragStart=e.onDragStart.bind(babelHelpers.assertThisInitialized(e));return e}babelHelpers.createClass(t,[{key:"enable",value:function e(){this.getDocument().addEventListener("mousedown",this.onMouseDown,true)}},{key:"disable",value:function e(){this.getDocument().removeEventListener("mousedown",this.onMouseDown,true)}},{key:"startHandleMouseUp",value:function e(){this.getDocument().addEventListener("mouseup",this.onMouseUp)}},{key:"stopHandleMouseUp",value:function e(){this.getDocument().removeEventListener("mouseup",this.onMouseUp)}},{key:"startHandleMouseMove",value:function e(){this.getDocument().addEventListener("mousemove",this.onMouseMove)}},{key:"stopHandleMouseMove",value:function e(){this.getDocument().removeEventListener("mousemove",this.onMouseMove)}},{key:"startPreventContextMenu",value:function e(){this.getDocument().addEventListener("contextmenu",this.preventDefaultEventAction,true)}},{key:"stopPreventContextMenu",value:function e(){this.getDocument().removeEventListener("contextmenu",this.preventDefaultEventAction,true)}},{key:"startPreventNativeDragAndDrop",value:function e(){this.getDocument().addEventListener("dragstart",this.preventDefaultEventAction)}},{key:"stopPreventNativeDragAndDrop",value:function e(){this.getDocument().removeEventListener("dragstart",this.preventDefaultEventAction)}},{key:"onMouseDown",value:function e(t){var r=this;if(!t.ctrlKey&&!t.metaKey&&!t.button){this.originalDragStartEvent=t;var n=this.getContainerByChild(t.target);if(n){var i=this.getDragElementByChild(t.target);if(i){this.startHandleMouseUp();this.startPreventNativeDragAndDrop();this.mousedownTimeoutId=setTimeout((function(){r.onDragStart()}),this.options.delay)}}}}},{key:"onDragStart",value:function e(){var t=this.getContainerByChild(this.originalDragStartEvent.target);this.dragStartEvent=new i({clientX:this.originalDragStartEvent.clientX,clientY:this.originalDragStartEvent.clientY,originalSource:this.originalDragStartEvent.target,originalEvent:this.originalDragStartEvent,sourceContainer:t});this.emit("drag:start",this.dragStartEvent);if(this.isDragging()){this.startPreventContextMenu();this.startHandleMouseMove()}}},{key:"onMouseMove",value:function e(t){if(this.isDragging()){var r=t.clientX,n=t.clientY;var i=this.getElementFromPoint(r,n);var a=this.getContainerByChild(i);var o=this.dragStartEvent.data,s=o.originalSource,u=o.sourceContainer;var c=new l({clientX:r,clientY:n,originalSource:s,sourceContainer:u,over:i,overContainer:a,originalEvent:t});this.emit("drag:move",c)}}},{key:"onMouseUp",value:function e(t){clearTimeout(this.mousedownTimeoutId);this.stopHandleMouseUp();this.stopPreventNativeDragAndDrop();if(this.isDragging()){var r=t.clientX,n=t.clientY;var i=this.getElementFromPoint(r,n);var a=this.getContainerByChild(i);var o=this.dragStartEvent.data,s=o.originalSource,l=o.sourceContainer;var h=new u({clientX:r,clientY:n,originalSource:s,sourceContainer:l,over:i,overContainer:a,originalEvent:t});this.emit("drag:end",h);if(!h.isDefaultPrevented()){var v=this.getDropzoneByChild(i);if(v){var p=new c({clientX:r,clientY:n,originalSource:s,sourceContainer:l,over:i,overContainer:a,originalEvent:t,dropzone:v});this.emit("drag:drop",p)}}this.stopPreventContextMenu();this.stopHandleMouseMove()}this.originalDragStartEvent=null}}]);return t}(s);var v=false;window.addEventListener("touchmove",(function(e){if(v){e.preventDefault()}}),{passive:false});var p=function(e){babelHelpers.inherits(t,e);function t(){var e;var r=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};babelHelpers.classCallCheck(this,t);e=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,r,n));e.tapTimeoutId=null;e.touchMoved=false;e.onTouchStart=e.onTouchStart.bind(babelHelpers.assertThisInitialized(e));e.onTouchEnd=e.onTouchEnd.bind(babelHelpers.assertThisInitialized(e));e.onTouchMove=e.onTouchMove.bind(babelHelpers.assertThisInitialized(e));e.onDragStart=e.onDragStart.bind(babelHelpers.assertThisInitialized(e));return e}babelHelpers.createClass(t,[{key:"enable",value:function e(){this.getDocument().addEventListener("touchstart",this.onTouchStart)}},{key:"disable",value:function e(){this.getDocument().removeEventListener("touchstart",this.onTouchStart)}},{key:"isTouchMoved",value:function e(){return this.touchMoved}},{key:"startPreventScrolling",value:function e(){v=true}},{key:"stopPreventScrolling",value:function e(){v=false}},{key:"startPreventContextMenu",value:function e(){this.getDocument().addEventListener("contextmenu",this.preventDefaultEventAction,true)}},{key:"stopPreventContextMenu",value:function e(){this.getDocument().removeEventListener("contextmenu",this.preventDefaultEventAction,true)}},{key:"startHandleTouchEvents",value:function e(){this.getDocument().addEventListener("touchmove",this.onTouchMove);this.getDocument().addEventListener("touchend",this.onTouchEnd);this.getDocument().addEventListener("touchcancel",this.onTouchEnd)}},{key:"stopHandleTouchEvents",value:function e(){this.getDocument().removeEventListener("touchmove",this.onTouchMove);this.getDocument().removeEventListener("touchend",this.onTouchEnd);this.getDocument().removeEventListener("touchcancel",this.onTouchEnd)}},{key:"onTouchStart",value:function e(t){var r=this;var n=this.getContainerByChild(t.target);if(n){var i=this.getDragElementByChild(t.target);if(i){this.originalDragStartEvent=t;this.startHandleTouchEvents();this.startPreventContextMenu();this.startPreventScrolling();this.tapTimeoutId=setTimeout((function(){if(!r.isTouchMoved()){r.onDragStart()}}),this.options.delay)}}}},{key:"onDragStart",value:function e(){var t=this.originalDragStartEvent.touches[0]||this.originalDragStartEvent.changedTouches[0];var r=this.getContainerByChild(this.originalDragStartEvent.target);this.dragStartEvent=new i({clientX:t.clientX,clientY:t.clientY,originalSource:this.originalDragStartEvent.target,originalEvent:this.originalDragStartEvent,sourceContainer:r});this.emit("drag:start",this.dragStartEvent)}},{key:"onTouchMove",value:function e(t){this.touchMoved=true;if(this.isDragging()){var r=t.touches[0]||t.changedTouches[0];var n=r.clientX,i=r.clientY;var a=this.getElementFromPoint(n,i);var o=this.getContainerByChild(a);var s=this.dragStartEvent.data,u=s.originalSource,c=s.sourceContainer;var h=new l({clientX:n,clientY:i,originalSource:u,sourceContainer:c,over:a,overContainer:o,originalEvent:t});this.emit("drag:move",h)}}},{key:"onTouchEnd",value:function e(t){clearTimeout(this.tapTimeoutId);this.stopPreventScrolling();this.stopPreventContextMenu();this.stopHandleTouchEvents();if(this.isDragging()){var r=t.touches[0]||t.changedTouches[0];var n=r.clientX,i=r.clientY;var a=this.getElementFromPoint(n,i);var o=this.getContainerByChild(a);var s=this.dragStartEvent.data,l=s.originalSource,h=s.sourceContainer;var v=new u({clientX:n,clientY:i,originalSource:l,sourceContainer:h,over:a,overContainer:o,originalEvent:t});this.emit("drag:end",v);if(!v.isDefaultPrevented()){var p=this.getDropzoneByChild(a);if(p){var g=new c({clientX:n,clientY:i,originalSource:l,sourceContainer:h,over:a,overContainer:o,originalEvent:t,dropzone:p});this.emit("drag:drop",g)}}}this.originalDragStartEvent=null;this.dragStartEvent=null;this.touchMoved=false}}]);return t}(s);var g=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var f=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var b=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var d=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var y=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var m=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var D=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var C=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var E=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var H=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var O=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var S=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var P=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var k=function(e){babelHelpers.inherits(t,e);function t(){babelHelpers.classCallCheck(this,t);return babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).apply(this,arguments))}return t}(n);var T,w,M;function x(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function A(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?x(Object(r),!0).forEach((function(t){babelHelpers.defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var z=[h,p];var L=Symbol("options");var R=Symbol("sensors");var B=Symbol("containers");var I=Symbol("dropzones");var X=function(e){babelHelpers.inherits(t,e);function t(){var e;var n;var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};babelHelpers.classCallCheck(this,t);n=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,i));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(n),L,{delay:0,sensors:[],draggable:".ui-draggable--item",type:"move",transitionDuration:150,dropzone:[],context:window,offset:{x:0,y:0}});babelHelpers.defineProperty(babelHelpers.assertThisInitialized(n),B,[]);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(n),I,[]);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(n),R,[]);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(n),"dragStartEvent",null);n.setEventNamespace("BX.UI.DragAndDrop.Draggable");n.cache=new r.Cache.MemoryCache;n.onDragStart=n.onDragStart.bind(babelHelpers.assertThisInitialized(n));n.onDragMove=n.onDragMove.bind(babelHelpers.assertThisInitialized(n));n.onDragEnd=n.onDragEnd.bind(babelHelpers.assertThisInitialized(n));n.onDragDrop=n.onDragDrop.bind(babelHelpers.assertThisInitialized(n));if(r.Type.isArray(i.container)||r.Type.isDomNode(i.container)||i.container instanceof NodeList){if(i.container instanceof NodeList){var a;(a=n).addContainer.apply(a,babelHelpers.toConsumableArray(i.container))}else{var o;(o=n).addContainer.apply(o,babelHelpers.toConsumableArray([i.container].flat()))}}else{throw new Error("Option container not a HTMLElement, Array of HTMLElement or NodeList")}if(!r.Type.isNil(i.dropzone)){if(r.Type.isArray(i.dropzone)||r.Type.isDomNode(i.dropzone)||i.dropzone instanceof NodeList){if(i.dropzone instanceof NodeList){var s;(s=n).addDropzone.apply(s,babelHelpers.toConsumableArray(i.dropzone))}else{var l;(l=n).addDropzone.apply(l,babelHelpers.toConsumableArray([i.dropzone].flat()))}}}n.setOptions(A(A({},n.getOptions()),i));var u=n.getOptions(),c=u.sensors;(e=n).addSensor.apply(e,[].concat(z,babelHelpers.toConsumableArray(c)));return n}babelHelpers.createClass(t,[{key:"getDocument",value:function e(){return this.getOptions().context.document}},{key:"getOptions",value:function e(){return this[L]}},{key:"setOptions",value:function e(t){this[L]=A({},t);if(!r.Type.isString(this[L].dragElement)){this[L].dragElement=this[L].draggable}if(!r.Type.isPlainObject(this[L].offset)){this[L].offset={x:0,y:0}}if(!r.Type.isNumber(this[L].offset.x)){this[L].offset.x=0}if(!r.Type.isNumber(this[L].offset.y)){this[L].offset.y=0}this.invalidateCache()}},{key:"isDragging",value:function e(){return this.dragStartEvent&&!this.dragStartEvent.isDefaultPrevented()}},{key:"getSensors",value:function e(){return this[R]}},{key:"addSensor",value:function e(){var t=this;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++){n[i]=arguments[i]}var a=n.map((function(e){var r=new e(t.getContainers(),t.getOptions());r.subscribe("drag:start",t.onDragStart);r.subscribe("drag:move",t.onDragMove);r.subscribe("drag:end",t.onDragEnd);r.subscribe("drag:drop",t.onDragDrop);r.enable();return r}));this[R]=[].concat(babelHelpers.toConsumableArray(this.getSensors()),babelHelpers.toConsumableArray(a))}},{key:"removeSensor",value:function e(){var t=this;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++){n[i]=arguments[i]}var a=this.getSensors().filter((function(e){return n.includes(e.constructor)}));a.forEach((function(e){e.unsubscribe("drag:start",t.onDragStart);e.unsubscribe("drag:move",t.onDragMove);e.unsubscribe("drag:end",t.onDragEnd);e.unsubscribe("drag:drop",t.onDragDrop);e.enable()}));this[R]=this.getSensors().filter((function(e){return!a.includes(e)}))}},{key:"getContainers",value:function e(){return this[B]}},{key:"getContainerByChild",value:function e(t){return this.getContainers().find((function(e){return e.contains(t)}))}},{key:"addContainer",value:function e(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++){n[i]=arguments[i]}this[B]=[].concat(babelHelpers.toConsumableArray(this.getContainers()),n);this[B].forEach((function(e){r.Dom.addClass(e,"ui-draggable--container")}));this.getSensors().forEach((function(e){e.addContainer.apply(e,n)}));this.invalidateContainersCache()}},{key:"removeContainer",value:function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++){r[n]=arguments[n]}this[B]=this.getContainers().filter((function(e){return!r.includes(e)}));this.getSensors().forEach((function(e){e.removeContainer.apply(e,r)}));this.invalidateContainersCache()}},{key:"getDropzones",value:function e(){return this[I]}},{key:"getDropzoneByChild",value:function e(t){return this.getDropzones().find((function(e){return e.contains(t)}))}},{key:"addDropzone",value:function e(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++){n[i]=arguments[i]}this[I]=[].concat(babelHelpers.toConsumableArray(this.getDropzones()),n);this[I].forEach((function(e){r.Dom.addClass(e,"ui-draggable--dropzone")}));this.getSensors().forEach((function(e){e.addDropzone.apply(e,n)}))}},{key:"removeDropzone",value:function e(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++){r[n]=arguments[n]}this[I]=this.getContainers().filter((function(e){return!r.includes(e)}));this.getSensors().forEach((function(e){e.removeDropzone.apply(e,r)}))}},{key:"getDraggableElements",value:function e(){var t=this;return this.cache.remember("draggableElements",(function(){return t.getContainers().reduce((function(e,r){return[].concat(babelHelpers.toConsumableArray(e),babelHelpers.toConsumableArray(t.getDraggableElementsOfContainer(r)))}),[])}))}},{key:"getDraggableElementsOfContainer",value:function e(t){var r=this;return this.cache.remember(t,(function(){var e=r.getOptions().draggable;var n=":not(.ui-draggable--draggable)";var i=":not(.ui-draggable--drop-preview)";var a="".concat(n).concat(i);var o="".concat(e).concat(a);var s=babelHelpers.toConsumableArray(t.querySelectorAll(o));return s.filter((function(e){return e.parentElement===t}))}))}},{key:"getLastDraggableElementOfContainer",value:function e(t){var r=this.getDraggableElementsOfContainer(t);return r[r.length-1]||null}},{key:"getElementIndex",value:function e(t){return this.getDraggableElements().indexOf(t)}},{key:"getDropPreview",value:function e(){var n=this;return this.cache.remember("dropPreview",(function(){var e=n.getOptions(),i=e.type;var a=n.getSource();if(a===null){return r.Tag.render(T||(T=babelHelpers.taggedTemplateLiteral(["<div></div>"])))}var o=n.getSourceClientRect();var s;if(i===t.CLONE){s=r.Runtime.clone(a);r.Dom.addClass(s,"ui-draggable--drop-preview-clone")}else{s=r.Tag.render(w||(w=babelHelpers.taggedTemplateLiteral(["<div></div>"])))}r.Dom.addClass(s,"ui-draggable--drop-preview");r.Dom.style(s,{width:"".concat(o.width,"px"),height:"".concat(o.height,"px")});return s}))}},{key:"move",value:function e(t,n){var i=n.x,a=i===void 0?0:i,o=n.y,s=o===void 0?0:o;var l=this.getOptions(),u=l.transitionDuration;requestAnimationFrame((function(){r.Dom.style(t,{transform:"translate3d(".concat(a,"px, ").concat(s,"px, 0px)"),transition:"all ".concat(u,"ms ease 0s")})}))}},{key:"setSource",value:function e(t){this.cache.set("source",t||null)}},{key:"getSource",value:function e(){return this.cache.get("source")||null}},{key:"getSourceClientRect",value:function e(){var t=this;return this.cache.remember("sourceClientRect",(function(){return t.cache.get("source").getBoundingClientRect()}))}},{key:"adjustDropPreview",value:function e(t){var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var i=n.x,a=i===void 0?false:i,o=n.y,s=o===void 0?false:o,l=n.force,u=l===void 0?true:l,c=n.skipOffset,h=c===void 0?false:c,v=n.transition,p=v===void 0?true:v;var g=this.getDropPreview();var f=r.Dom.getRelativePosition(t,t.parentElement);var b=r.Dom.getRelativePosition(g,g.parentElement);var d=0;if(b.height!==0&&!h){if(f.height>b.height){if(f.top>b.top){d=f.height-b.height}}else if(f.top>b.top){d=-Math.abs(f.height-b.height)}}var y=this.getOptions(),m=y.transitionDuration;var D=function e(){var t={transition:p?"all ".concat(m,"ms ease 0ms"):"null"};if(s){t.top="".concat(f.top+d,"px")}if(a){t.left="".concat(f.left,"px")}r.Dom.style(g,t)};if(u){D()}else{requestAnimationFrame(D)}}},{key:"showDropPreviewAfter",value:function e(t){var n=this;var i=r.Dom.getRelativePosition(t,t.parentElement);var a=r.Text.toNumber(r.Dom.style(t,"margin-bottom"));var o=r.Text.toNumber(r.Dom.style(t,"margin-top"));var s=i.bottom+a+o;var l=this.getOptions(),u=l.transitionDuration;requestAnimationFrame((function(){r.Dom.style(n.getDropPreview(),{top:"".concat(s,"px"),transition:"all ".concat(u,"ms ease 0s")})}))}},{key:"pushDraggableElementToContainer",value:function e(t,n){var i=this.getLastDraggableElementOfContainer(n);if(i){r.Dom.insertAfter(t,i)}else{r.Dom.append(t,n)}this.invalidateContainersCache()}},{key:"resetDraggableElementsPosition",value:function e(t){var n=this;var i=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},a=i.transition,o=a===void 0?true:a;var s=function(){if(t){return n.getDraggableElementsOfContainer(t)}return n.getDraggableElements()}();s.forEach((function(e){r.Dom.style(e,{transform:null,transition:!o?"none":undefined})}))}},{key:"resetDraggableElementsTransition",value:function e(t){var n=this;var i=function(){if(t){return n.getDraggableElementsOfContainer(t)}return n.getDraggableElements()}();i.forEach((function(e){r.Dom.style(e,{transition:null})}))}},{key:"getSortOffsetY",value:function e(){var t=this;return this.cache.remember("sortOffsetY",(function(){var e=t.getSource();var n=t.getSourceClientRect();var i=r.Text.toNumber(r.Dom.style(e,"margin-top"));var a=r.Text.toNumber(r.Dom.style(e,"margin-bottom"));return n.height+(i+a)}))}},{key:"getSortOffsetX",value:function e(){var t=this;return this.cache.remember("sortOffsetX",(function(){var e=t.getSource();var n=t.getSourceClientRect();var i=r.Text.toNumber(r.Dom.style(e,"margin-left"));var a=r.Text.toNumber(r.Dom.style(e,"margin-right"));return n.width+(i+a)}))}},{key:"getElementMiddlePoint",value:function e(t){var r=t.getBoundingClientRect();return{x:r.left+r.width/2,y:r.top+r.height/2}}},{key:"getDraggableElementByChild",value:function e(t){return t.closest(this.getOptions().draggable)}},{key:"splitDraggableElementsListByPoint",value:function e(t,r){var n=this;var i=true;return this.getDraggableElementsOfContainer(t).reduce((function(e,t){if(i){var a=n.getElementMiddlePoint(t);if(a.y<r.y){e[0].push(t)}else{e[1].push(t);i=false}}else{e[1].push(t)}return e}),[[],[]])}},{key:"invalidateContainersCache",value:function e(){var t=this;this.cache["delete"]("draggableElements");this.getContainers().forEach((function(e){return t.cache["delete"](e)}))}},{key:"invalidateCache",value:function e(){this.cache["delete"]("source");this.cache["delete"]("sourceClientRect");this.cache["delete"]("dropPreview");this.cache["delete"]("sortOffsetY");this.cache["delete"]("sortOffsetX");this.cache["delete"]("sourceLeftOffset");this.cache["delete"]("sourceLeftMargin");this.invalidateContainersCache()}},{key:"isDepthEditorEnabled",value:function e(){var n=this.getOptions(),i=n.depth,a=n.type;return r.Type.isPlainObject(i)&&(a===t.DROP_PREVIEW||a===t.CLONE)}},{key:"getDepthProperty",value:function e(){var t=this.getOptions(),r=t.depth;return r.property||"margin-left"}},{key:"getDepthMargin",value:function e(){var t=this.getOptions(),n=t.depth;return r.Text.toNumber(n.margin)||20}},{key:"getElementDepth",value:function e(t){return r.Text.toNumber(r.Dom.attr(t,"data-depth"))}},{key:"setElementDepth",value:function e(t,n){r.Dom.attr(t,"data-depth",n);var i=this.getDepthMargin();var a=this.getSourceLeftMargin();var o=i*n+a;r.Dom.style(t,this.getDepthProperty(),"".concat(o,"px"))}},{key:"getStartSourceDepth",value:function e(){return this.dragStartEvent.data.sourceDepth}},{key:"getSourceWidth",value:function e(){return this.getSourceClientRect().width}},{key:"getSourceLeftOffset",value:function e(){var t=this;return this.cache.remember("sourceLeftOffset",(function(){var e=t.getSource();var n=r.Dom.getRelativePosition(e,e.parentElement);var i=t.getStartSourceDepth()*t.getDepthMargin();return n.left-i}))}},{key:"getSourceLeftMargin",value:function e(){var t=this;return this.cache.remember("sourceLeftMargin",(function(){var e=t.getSource();var n=t.getStartSourceDepth();var i=t.getDepthMargin();var a=n*i;var o=r.Text.toNumber(r.Dom.style(e,t.getDepthProperty()));return o-a}))}},{key:"setDropPreviewDepth",value:function e(t){var n=this.getStartSourceDepth();var i=this.getSourceWidth();var a=this.getDepthMargin();var o=this.getSourceLeftOffset();var s=function(){var e=Math.abs(n-t);if(t>n){return i-e*a}if(t<n){return i+e*a}return i}();r.Dom.style(this.getDropPreview(),{left:"".concat(t*a+o,"px"),width:"".concat(s,"px")})}},{key:"calcDepthByOffset",value:function e(t){var r=this.getStartSourceDepth();var n=this.getDepthMargin();var i=r*n;return Math.max(0,Math.floor((t+i)/n))}},{key:"getChildren",value:function e(t){var r=this;var n=this.getElementDepth(t);var i=t.getBoundingClientRect();var a=this.getContainerByChild(t);var o=this.splitDraggableElementsListByPoint(a,{x:i.left,y:i.bottom}),s=babelHelpers.slicedToArray(o,2),l=s[1];var u=false;return l.reduce((function(e,t){if(!u){var i=r.getElementDepth(t);if(i>n){return[].concat(babelHelpers.toConsumableArray(e),[t])}u=true}return e}),[])}},{key:"getPreviousElement",value:function e(t){var n=t.getBoundingClientRect();var i=this.getContainerByChild(t);var a=this.splitDraggableElementsListByPoint(i,{x:n.left,y:n.top}),o=babelHelpers.slicedToArray(a,1),s=o[0];if(r.Type.isArrayFilled(s)){return s.pop()}return null}},{key:"onDragStart",value:function e(n){var i=n.data,a=i.originalSource,o=i.sourceContainer,s=i.clientX,l=i.clientY;var u=this.getDraggableElementByChild(a);var c=new g({clientX:s,clientY:l,source:u,sourceContainer:o,originalSource:a});this.emit("beforeStart",c);if(c.isDefaultPrevented()){n.preventDefault();return}this.setSource(u);var h=this.getElementDepth(u);var v=this.getSourceClientRect();var p=s-v.left;var b=l-v.top;var d=this.getOptions(),y=d.type;var m=u;if(y!==t.HEADLESS){var D=r.Runtime.clone(u);r.Dom.style(D,"margin",0);m=r.Tag.render(M||(M=babelHelpers.taggedTemplateLiteral(["<div>","</div>"])),D);r.Dom.style(m,{width:"".concat(v.width,"px"),height:"".concat(v.height,"px"),top:"".concat(l-b+this.getOptions().offset.y,"px"),left:"".concat(s-p+this.getOptions().offset.x,"px")});r.Dom.addClass(m,"ui-draggable--draggable");this.pushDraggableElementToContainer(m,o);if(this.isDepthEditorEnabled()){var C=this.getChildren(u);this.childrenElements=C;if(C.length>0){r.Dom.append(r.Runtime.clone(D),m);C.forEach((function(e){r.Dom.style(e,"display","none")}))}}}var E=this.getDropPreview();if(y===t.DROP_PREVIEW||y===t.CLONE){this.pushDraggableElementToContainer(E,o);this.adjustDropPreview(u,{force:true,x:true,y:true,transition:false})}r.Dom.addClass(u,"ui-draggable--source");r.Dom.addClass(this.getDocument().body,"ui-draggable--disable-user-select");r.Dom.addClass(this.getDocument().body,"ui-draggable--type-".concat(this.getOptions().type));var H=this.getElementIndex(u);this.dragStartEvent=new f({clientX:s,clientY:l,pointerOffsetX:p,pointerOffsetY:b,draggable:m,dropPreview:E,source:u,sourceIndex:H,sourceContainer:o,sourceDepth:h,originalSource:a});this.emit("start",this.dragStartEvent);if(this.dragStartEvent.isDefaultPrevented()){n.preventDefault()}}},{key:"onDragMove",value:function e(n){var i=this;if(!this.isDragging()){return}var a=n.data,o=a.clientX,s=a.clientY,l=a.sourceContainer,u=a.originalSource;var c=this.dragStartEvent.data,h=c.clientX,v=c.clientY,p=c.pointerOffsetX,g=c.pointerOffsetY,f=c.source,H=c.sourceIndex,k=c.draggable,T=c.dropPreview;var w=o-h;var M=s-v;var x=new b({clientX:o,clientY:s,offsetX:w,offsetY:M,pointerOffsetX:p,pointerOffsetY:g,draggable:k,dropPreview:T,source:f,sourceIndex:H,sourceContainer:l,originalSource:u});this.emit("move",x);if(x.isDefaultPrevented()){n.preventDefault()}if(!r.Type.isDomNode(n.data.over)){return}var z=n.data.over;var L=this.getDraggableElementByChild(z);var R=this.getContainerByChild(z);var B=this.getOptions(),I=B.type;if(I!==t.HEADLESS){r.Dom.style(k,{top:"".concat(s-g+this.getOptions().offset.y,"px"),left:"".concat(o-p+this.getOptions().offset.x,"px")});if(R&&R.contains(f)&&!this.stopMove){var X=this.getSortOffsetY();var N=this.getDraggableElementsOfContainer(R);var Y=N.indexOf(f);N.forEach((function(e,t){if(e!==f){var r=e.style.transform;var n=i.getElementMiddlePoint(e);if(n.y===0){return}if(t>Y&&s>n.y&&r!=="translate3d(0px, ".concat(-X,"px, 0px)")){i.adjustDropPreview(e,{y:true});i.move(e,{y:-X});i.insertType="after";i.insertElement=e}if(t<Y&&s<n.y&&r!=="translate3d(0px, ".concat(X,"px, 0px)")){i.adjustDropPreview(e,{y:true});i.move(e,{y:X});i.insertType="before";i.insertElement=e}if((t<Y&&s>n.y||t>Y&&s<n.y)&&r!=="translate3d(0px, 0px, 0px)"&&r!==""){i.adjustDropPreview(e,{y:true});i.move(e,{y:0});i.insertElement=e;if(t<Y&&s>n.y){i.insertType="after"}if(t>Y&&s<n.y){i.insertType="before"}}}}))}}if(this.isDepthEditorEnabled()){var j=this.calcDepthByOffset(w);var U=this.getPreviousElement(T);if(U){var F=this.getElementDepth(U);var W=0;var V=Math.max(W,F+1);j=Math.max(W,Math.min(j,V))}else{j=0}this.setDropPreviewDepth(j);this.currentDepth=j}if(r.Type.isDomNode(L)&&f!==L){var _=new d(A(A({},x.data),{},{over:L,originalOver:z,overContainer:R}));this.emit("over",_);if(!_.isDefaultPrevented()){r.Dom.addClass(L,"ui-draggable--over")}if(L!==this.lastOver){var q=new m(A(A({},x.data),{},{enter:L,enterContainer:R}));this.emit("enter",q)}}this.lastOver=this.lastOver||L;if(!L||L!==this.lastOver){if(this.lastOver){var K=this.getContainerByChild(this.lastOver);var G=new C(A(A({},x),{},{out:this.lastOver,outContainer:K}));this.emit("out",G);r.Dom.removeClass(this.lastOver,"ui-draggable--over")}this.lastOver=L}var J=this.getDocument().elementFromPoint(o,s);var Q=this.getDropzoneByChild(J);if(Q){var Z=new O(A(A({},x.data),{},{dropzone:Q}));this.emit("dropzone:over",Z);if(Q!==this.lastOverDropzone){var $=new S(A(A({},x.data),{},{dropzone:Q}));this.emit("dropzone:enter",$)}}this.lastOverDropzone=this.lastOverDropzone||Q;if(Q!==this.lastOverDropzone){var ee=new P(A(A({},x.data),{},{dropzone:this.lastOverDropzone}));this.emit("dropzone:out",ee);this.lastOverDropzone=Q}if(R){var te=new y(A(A({},x.data),{},{over:R}));this.emit("container:over",te);if(R!==this.lastOverContainer){var re=new D(A(A({},x.data),{},{enter:R}));this.emit("container:enter",re);if(!R.contains(f)){var ne=this.getContainerByChild(f);var ie=this.splitDraggableElementsListByPoint(R,{x:o,y:s}),ae=babelHelpers.slicedToArray(ie,2),oe=ae[0],se=ae[1];if(I===t.DROP_PREVIEW||I===t.CLONE){this.stopMove=true;setTimeout((function(){i.stopMove=false}),300);this.pushDraggableElementToContainer(this.getDropPreview(),R)}if(I!==t.HEADLESS){this.pushDraggableElementToContainer(f,R)}if(r.Type.isArrayFilled(oe)){var le=oe[oe.length-1];if(I===t.DROP_PREVIEW||I===t.CLONE){this.showDropPreviewAfter(le)}this.insertType="after";this.insertElement=le}else if(r.Type.isArrayFilled(se)){var ue=babelHelpers.slicedToArray(se,1),ce=ue[0];if(I===t.DROP_PREVIEW||I===t.CLONE){this.adjustDropPreview(se)}this.insertType="before";this.insertElement=ce}this.resetDraggableElementsTransition(ne);this.resetDraggableElementsPosition(ne);if(I!==t.HEADLESS){if(r.Type.isArrayFilled(se)){var he=this.getSortOffsetY();se.forEach((function(e){i.move(e,{y:he})}))}}}}}this.lastOverContainer=this.lastOverContainer||R;if(R!==this.lastOverContainer){var ve=new E(A(A({},x.data),{},{out:this.lastOverContainer}));this.emit("container:out",ve);this.lastOverContainer=R}}},{key:"onDragEnd",value:function e(n){var i=this;var a=new H(A(A({},this.dragStartEvent.data),{},{clientX:n.data.clientX,clientY:n.data.clientY,end:this.lastOver,endContainer:this.lastOverContainer}));var o=this.dragStartEvent.data,s=o.source,l=o.draggable;if(this.getOptions().type!==t.HEADLESS){r.Dom.remove(l)}r.Dom.removeClass(s,"ui-draggable--source");this.getDraggableElements().forEach((function(e){r.Dom.removeClass(e,"ui-draggable--draggable");r.Dom.removeClass(e,"ui-draggable--over")}));r.Dom.remove(this.getDropPreview());this.resetDraggableElementsPosition();this.resetDraggableElementsTransition();if(this.getOptions().type!==t.HEADLESS){if(r.Type.isString(this.insertType)){if(this.insertType==="after"){r.Dom.insertAfter(s,this.insertElement)}else{r.Dom.insertBefore(s,this.insertElement)}}}if(this.isDepthEditorEnabled()){var u=this.getStartSourceDepth();var c=function(){if(r.Type.isNumber(i.currentDepth)){return i.currentDepth-u}return 0}();var h=s;this.childrenElements.forEach((function(e){var t=i.getElementDepth(e);i.setElementDepth(e,t+c);r.Dom.insertAfter(e,h);r.Dom.style(e,"display",null);h=e}));if(r.Type.isNumber(this.currentDepth)){this.setElementDepth(s,this.currentDepth)}}this.lastOver=null;this.lastOverContainer=null;this.insertType=null;this.lastOverDropzone=null;this.childrenElements=[];this.currentDepth=null;this.invalidateCache();r.Dom.removeClass(this.getDocument().body,"ui-draggable--disable-user-select");r.Dom.removeClass(this.getDocument().body,"ui-draggable--type-".concat(this.getOptions().type));this.emit("end",a)}},{key:"onDragDrop",value:function e(t){var r=new k(A(A({},this.dragStartEvent.data),{},{clientX:t.data.clientX,clientY:t.data.clientY,dropzone:t.data.dropzone}));this.emit("drop",r)}}]);return t}(t.EventEmitter);babelHelpers.defineProperty(X,"MOVE","move");babelHelpers.defineProperty(X,"CLONE","clone");babelHelpers.defineProperty(X,"DROP_PREVIEW","drop-preview");babelHelpers.defineProperty(X,"HEADLESS","headless");e.Draggable=X;e.DragStartEvent=f;e.DragMoveEvent=b;e.DragOutEvent=C;e.DragOutContainerEvent=E;e.DragEndEvent=H;e.DragOverEvent=d;e.DragOverContainerEvent=y;e.DragEnterEvent=m;e.DragEnterContainerEvent=D})(this.BX.UI.DragAndDrop=this.BX.UI.DragAndDrop||{},BX.Event,BX);
//# sourceMappingURL=draggable.bundle.map.js